/* eslint-disable no-undef */
/* eslint-disable no-unused-vars */
const appid = invokeAPi('xz_get_app_id') // 项目id
let isMember = false
let userInfo = {}
getMemberInfo()
getUserInfo()
// 通知登录状态
registerInformApi('inform_LoginStatus', bool => {
  if (bool) {
    getUserInfo()
  } else {
    userInfo = {}
  }
})
// VIP
registerInformApi('inform_UpdateVip', () => {
  getMemberInfo()
})
function getMemberInfo () {
  let rightsId = 10011
  if (appid === 125) {
    rightsId = 70001
  }
  invokeAsyncAPi('xz_get_rights_info', rightsId).then(res => {
    isMember = res
  }).catch(e => {
    isMember = false
  })
}
function getUserInfo () {
  invokeAsyncAPi('xz_get_UserInfo').then(res => {
    if (res && res.user_id) {
      userInfo = res
    }
  })
}
function reportInfo (code, info) {
  info.user_id = (userInfo.user_id || '') + ''
  info.param1 = isMember ? 1 : 0
  invokeAsyncAPi('xz_submit_info_report', code, JSON.stringify(info))
}
